package com.cmeizu.webconfigdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author cmeizu
 * @date 2020/6/20 9:49
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean(value = "study")
    public Docket studyRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cmeizu.webconfigdemo.controller"))
                .paths(PathSelectors.any())
                .build().apiInfo(getStudyInfo());
    }

    private ApiInfo getStudyInfo() {
        return new ApiInfoBuilder()
                .title("SpringBoot学习")
                .description("study!")
                .version("1.0")
                .license("The Apache license")
                .licenseUrl("http://cmeizu.cn")
                .build();
    }
}
